package com.open.demo.flow

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch

/**
 *
 * @Author: hailong.qiu hailong.qiu@xgimi.com
 * @Maintainer: hailong.qiu hailong.qiu@xgimi.com
 * @Date: 2021/8/3
 * @Copyright: 2021 www.xgimi.com Inc. All rights reserved.
 */
class LatestNewsViewModel:ViewModel() {

    val newsRepository: NewRepository by lazy { NewRepository() }

    init {
        viewModelScope.launch {
            newsRepository.favoriteLatestNews
                .catch { exception ->

                }
                .collect { favoriteNews ->
                }
        }
    }
}